package es.ikex.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class EliminarCookie extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Cookie cookies[] = request.getCookies();
		Cookie a;
		for(int i = 0; i<cookies.length; i++){
			if(!cookies[i].getName().equals("politicaCookies")){
				a = new Cookie(cookies[i].getName(), "");
				a.setMaxAge(0);
				a.setPath("/");
				response.addCookie(a);
			}
		}
		request.getRequestDispatcher("/jsp/compraFinalizada.jsp").forward(request, response);
	}

}
